<template>
    <el-result title="401" :sub-title="`${time}秒后跳转至${resu.msg.title}`">
    <template #icon>
        <CircleCloseFilled style="font-size: 4px; margin-left: 5px;"/>
        <br>
        <slot></slot>
    </template>
    <template #extra>
      <el-button type="primary" @click="returnHome">立即跳转</el-button>
    </template>
  </el-result>
</template>

<script setup>
// 错误组件
import {ref} from 'vue'
import router from "@/router";
import {defineProps}  from 'vue'
const resu = defineProps({
    msg:{
        type:Object,
        requid:true
    },
})
const time = ref(5) // 计时，初始五秒
const timer = setInterval(()=>{
    // 当定时器减到1时，进行路由跳转
    if (time.value===1){
        router.push(resu.msg.path)
        clearInterval(timer) // 关闭定时器
    }
    time.value--
},1000)
// console.log(msg);
// 点击跳转至主页
const returnHome = ()=>{
    router.push(resu.msg.path)
    clearInterval(timer)
}

</script>

<style lang="scss">
</style>